# -*- coding: utf-8 -*-
"""
Spyder 编辑器

这是一个临时脚本文件。
"""

shopping_list = []
print(shopping_list)

# 2. 向清单添加"牛奶"、"面包"

# .append()

shopping_list.append('牛奶') 
shopping_list.append('面包')
print(shopping_list)
# 3. 在"牛奶"后插入"鸡蛋"
# 
# .insert()

shopping_list.insert(1, '鸡蛋')
print(shopping_list)
# 4. 查看清单第2个物品

# 索引 [index]
index=2
second_item = shopping_list[index]
print(second_item)
# 5. 删除"面包"
# .remove()

shopping_list.remove('面包')
print(shopping_list)
# 6. 检查是否包含"苹果"

# in 关键字

has_apple = '苹果' in shopping_list
print(has_apple)
# 7. 获取清单长度

# len()

list_length = len(shopping_list)
print(list_length)
# 8. 对清单按字母排序

# .sort()

shopping_list.sort()
print(shopping_list)
# 9. 清空整个清单

# .clear()

shopping_list.clear()
print(shopping_list)
# output:[]
# ['牛奶', '面包']
# ['牛奶', '鸡蛋', '面包']
# 面包
# ['牛奶', '鸡蛋']
# False
# 2
# ['牛奶', '鸡蛋']
# []